package com.fulu.game.bi.controller.common;

import com.fulu.game.bi.entity.enums.OsEnum;
import com.fulu.game.bi.entity.vo.Result;
import com.fulu.game.bi.entity.vo.common.IdNameVO;
import com.fulu.game.bi.entity.vo.common.NameMsgVO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/api/v1/stat-map")
public class StatMapController {

    /**
     * 统计参数类型
     */
    @RequestMapping("/os")
    public Result<List<IdNameVO>> os() {
        List<IdNameVO> list = Arrays.stream(OsEnum.values())
                .map(osEnum -> {
                    IdNameVO idNameVO = new IdNameVO();
                    idNameVO.setId(osEnum.getType());
                    idNameVO.setName(osEnum.getMsg());
                    return idNameVO;
                })
                .collect(Collectors.toList());
        return Result.success().data(list).msg("获取成功");
    }

    @RequestMapping("/stat")
    public Result<List<NameMsgVO>> stat() {
        Map<String, String> cacheMap = new LinkedHashMap<>();
        cacheMap.put("新增激活用户数", "newActiveUserNum");
        cacheMap.put("新增注册用户数", "newRegistUserNum");
        cacheMap.put("注册转化率", "loginRate");

        cacheMap.put("新增标签用户数", "newLabelUserNum");
        cacheMap.put("充值总人数", "investUserAll");
        cacheMap.put("充值总次数", "investNum");
        cacheMap.put("充值总金额", "investMoneyAll");
        cacheMap.put("付费转化率", "payRate");

        cacheMap.put("皮皮币充值人数", "pipiMoneyInvestUserNum");
        cacheMap.put("皮皮币充值次数", "pipiMoneyInvestNum");
        cacheMap.put("皮皮币充值金额", "pipiMoneyInvestAll");

        cacheMap.put("钻石充值人数", "virtualMoneyInvestUserNum");
        cacheMap.put("钻石充值次数", "virtualMoneyInvestNum");
        cacheMap.put("钻石充值金额", "virtualMoneyInvestAll");

        cacheMap.put("消费总人数", "consumeUserAll");
        cacheMap.put("消费总次数", "consumeNum");
        cacheMap.put("消费总金额", "consumeMoneyAll");

        cacheMap.put("皮皮币消费人数", "pipiMoneyConsumeUserNum");
        cacheMap.put("皮皮币消费次数", "pipiMoneyConsumeNum");
        cacheMap.put("皮皮币消费金额", "pipiMoneyConsumeAll");

        cacheMap.put("钻石消费人数", "virtualMoneyConsumeUserNum");
        cacheMap.put("钻石消费次数", "virtaulMoneyConsumeNum");
        cacheMap.put("钻石消费金额", "virtualMoneyConsumeAll");

        cacheMap.put("订单支付人数", "orderUserNum");
        cacheMap.put("订单支付次数", "orderNum");
        cacheMap.put("订单支付金额", "orderMoneyAll");

        cacheMap.put("订单退款人数", "refundUserNum");
        cacheMap.put("订单退款次数", "refundNum");
        cacheMap.put("订单退款金额", "refundMoneyAll");

        cacheMap.put("优惠券使用金额", "couponMoneyAll");
        cacheMap.put("优惠券退款金额", "refundCouponMoneyAll");

        cacheMap.put("皮皮币礼物消费人数", "pipiGiftUserNum");
        cacheMap.put("皮皮币礼物消费次数", "pipiGiftNum");
        cacheMap.put("皮皮币礼物消费金额", "pipiGiftConsumeAll");


        List<NameMsgVO> list = cacheMap.entrySet().stream()
                .map(entry -> {
                    NameMsgVO idNameVO = new NameMsgVO();
                    idNameVO.setName(entry.getValue());
                    idNameVO.setMsg(entry.getKey());
                    return idNameVO;
                })
                .collect(Collectors.toList());

        return Result.success().data(list).msg("获取成功");
    }


}
